package Model.Beans;

import java.beans.*;
import java.io.Serializable;
import Model.XML.*;

public class Person extends Object implements Serializable, XMLRequestInterface {
    private int id = 0;
    private String name = "";
    private String firstLastName = "";
    private String secondLastName = "";
    private XMLWriter xml;
    
    public Person() 
    {
        xml = new XMLWriter();
    }
    
    public Person(int id, String name, String firstLastName, String secondLastName)
    {
        this.id = id;
        this.name = name;
        this.firstLastName = firstLastName;
        this.secondLastName = secondLastName;
        xml = new XMLWriter();
    }
    
    public Person(String name, String firstLastName, String secondLastName)
    {
        this(0, name, firstLastName, secondLastName);
    }
    
    public int getId()
    {
        return id;
    }
    
    public void setId(int id)
    {
        this.id = id;
    }
    
    public String getName()
    {
        return name;
    }
    
    public void setName(String name)
    {
        this.name = name;
    }
    
    public String getFirstLastName()
    {
        return firstLastName;
    }
    
    public void setFistLastName(String firstLastName)
    {
        this.firstLastName = firstLastName;
    }
    
    public String getSecondLastName()
    {
        return secondLastName;
    }
    
    public void setSecondLastName(String secondLastName)
    {
        this.secondLastName = secondLastName;
    }
    
    public String toString()
    {
        StringBuilder result = new StringBuilder();
        result.append(name + " " + firstLastName + " " + secondLastName);
        return result.toString();
    }
    
    public String toXML()
    {
        xml.Push("Person");
        xml.Element("id", Integer.toString(this.id));
        xml.Element("name", this.name);
        xml.Element("firstLastName", this.firstLastName);
        xml.Element("secondLastName", this.secondLastName);
        xml.Pop();
        return xml.GetXML();
    }
}